import { _fetch } from '@/utils/request.js'

export function apiGetCompanyList ({
  start,
  limit,
  q,
  distance,
  score,
  scoreRange
}) {
  return _fetch({
    url: '/companies/list',
    params: {
      start,
      limit,
      q,
      distance,
      score,
      scoreRange
    }
  })
}
/**
 * 点赞文章评论接口
 * @param {} data
 */
export function starArticleComment (data) {
  return _fetch({
    url: '/article-comments/star',
    method: 'post',
    // 4.需要带token
    needToken: true,
    data
  })
}
// 获取当前公司的文章
export function companyDetail (id) {
  return _fetch({
    url: `/companies/${id}`,
    method: 'GET'
  })
}

// 企业评论数据
export function companyComments (data) {
  const { id, limit, start } = data
  return _fetch({
    url: `/companies/${id}/comments`,
    method: 'get',
    params: {
      limit,
      start
    }
  })
}

/**
 * 添加评论数据
 * @param {} params
 */
export function addComment (data) {
  return _fetch({
    url: '/comments',
    method: 'post',
    // 4.需要带token
    needToken: true,
    data
  })
}
/**
 * 企业职位数据
 * @param {} params
 */
export function companyPositions (data) {
  const { id, limit, start, city, experience, salary, type } = data
  return _fetch({
    url: `/companies/${id}/positions`,
    method: 'get',
    params: {
      limit,
      start,
      city,
      experience,
      salary,
      type
    }
  })
}
/**
 * 获取职位详情
 * @param {} params
 */
export function positionDetail (id) {
  return _fetch({
    url: `/positions/${id}`,
    method: 'get'
  })
}

/**
 * 获取职位筛选条件
 * @param {} params
 */
export function positionFilters (id) {
  return _fetch({
    url: `/companies/${id}/positionFilters`,
    method: 'get'
  })
}
/**
 * 面试题筛选条件获取
 * @param {} data
 */
export function questionFilters (id) {
  return _fetch({
    url: `/questions/companyFilters/${id}`,
    method: 'get',
    // 4.需要带token
    needToken: true
  })
}
/**
 * 获取模拟面试面试题数据
 * @param {} data
 */
export function interviewQuestions (params) {
  return _fetch({
    url: '/interview/questions',
    method: 'get',
    // 4.需要带token
    needToken: true,
    params
  })
}

/**
 * 获取面试题数据
 * @param {} data
 */
export function companyQuestion (params) {
  const { id, position, difficulty } = params
  return _fetch({
    url: `/questions/company/${id}`,
    method: 'get',
    params: {
      position,
      difficulty
    },
    // 4.需要带token
    needToken: true
  })
}
/**
 * 提交面试题
 * @param {} data
 */
export function submitQuestion (data) {
  return _fetch({
    url: '/questions/submit',
    method: 'post',
    data,
    // 4.需要带token
    needToken: true
  })
}
/**
 * 面试题详情
 * @param {} data
 */
export function questionDetail (id) {
  return _fetch({
    url: `/questions/${id}`,
    method: 'get',
    // 4.需要带token
    needToken: true
  })
}
/**
 * 收藏面试题
 * @param {} data
 */
export function collectQuestion (data) {
  return _fetch({
    url: '/questions/collect',
    method: 'post',
    // 4.需要带token
    needToken: true,
    data
  })
}
